<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<link type="text/css" href="<%=basePath %>css/all_guanli.css" rel="stylesheet" />
<div id="content_whole">
          <div id="top">
 <div id="top_whole">
         <div id="top_left">
                <img src="<%=basePath %>images/41.png" />
         </div>
          <div id="top_right">
                <h1>管家管理系统</h1>
               <p><span>管理员</span><span><b>${sessionScope.user.name}</b></span><span><a href="#"  onclick="Open_Dialog()">修改密码</a></span><span><a href="#" id="loginOut">安全退出</a></span></p>
          </div>
  </div>
  </div>
  </div>
  

<div id="mydialog"  icon="icon-save"  style="width: 300px; height: 150px; padding: 5px; display:none;
        background: #fafafa;" title="修改密码">

            <div region="center" border="false" style="padding: 10px; background: #fff; border: 1px solid #ccc;">
                <table cellpadding=3>
                    <tr>
                        <td>新密码：</td>
                        <td><input id="txtNewPass" type="Password" class="txt01" /></td>
                    </tr>
                    <tr>
                        <td>确认密码：</td>
                        <td><input id="txtRePass" type="Password" class="txt01" /></td>
                    </tr>
                </table>
            </div>

<label id="lbmsg" runat="server"></label>
</div> 

    <script type="text/javascript" charset="utf-8">
        $(function() {
            $('#loginOut').click(function() {
                $.messager.confirm('系统提示', '您确定要退出本次登录吗?', function(r) {
                    if (r) {
                        location.href = '${pageContext.request.contextPath}/loginAction!cancel.action';
                    }
                });

            })
        });


		function Open_Dialog() {
			$('#mydialog').show();
				$('#mydialog').dialog({
					collapsible: true,
					minimizable: true,
					maximizable: true,
					
				buttons: [{
					text: '提交',
					iconCls: 'icon-ok',
					handler: function() {
					serverLogin();
				}
				}, {
					text: '取消',
					handler: function() {
					$('#mydialog').dialog('close');
					}
				}]
			});
		} 
		
	//关闭修改密码窗口
        function close() {
           $('#mydialog').dialog('close');
        }
		 //修改密码
        function serverLogin() {
            var $newpass = $('#txtNewPass');
            var $rePass = $('#txtRePass');

            if ($newpass.val() == '') {
                alert('请输入密码！');
                return false;
            }
            if ($rePass.val() == '') {
                alert('请再一次输入密码！');
                return false;
            }

            if ($newpass.val() != $rePass.val()) {
                alert('两次密码不一至！请重新输入');
                return false;
            }

            $.post('${pageContext.request.contextPath}/tuserAction!updatePwd.action?newpass=' + $newpass.val(), function(msg) {
                $.messager.alert('标题','恭喜，密码修改成功!');
                $newpass.val('');
                $rePass.val('');
                close();
            })
            
        }
    </script>